FILE *fd;
FILE *ofd;
+#define MYNAME "geo"
+
static void
tag_coord(const char **attrv)
{
{
fd = fopen(fname, "r");
if (fd == NULL) {
- abort();
+ fatal(MYNAME ":Can not open %s for reading\n");
}
psr = XML_ParserCreate(NULL);
if (!psr) {
- abort();
+ fatal(MYNAME ":Can not create XML parser\n");
}
XML_SetElementHandler(psr, geo_start, geo_end);
{
ofd = fopen(fname, "w");
if (ofd == NULL) {
- abort();
+ fatal(MYNAME ":Can not open %s for writing\n");
}
}
while ((len = fread(buf, 1, sizeof(buf), fd))) {
if (!XML_Parse(psr, buf, len, feof(fd))) {
- fprintf(stderr, "Parse error at %d: %s\n",
+ fatal(MYNAME ":Parse error at %d: %s\n",
XML_GetCurrentLineNumber(psr),
XML_ErrorString(XML_GetErrorCode(psr)));
- exit(1);
}
}
fprintf(ofd, "<wpt lat=\"%lf\" lon=\"%lf\">\n",
waypointp->position.latitude.degrees,
waypointp->position.longitude.degrees);
- fprintf(ofd, "<name>%s</name>\n", waypointp->shortname);
+ fprintf(ofd, "<name>%s</name>\n", global_opts.synthesize_shortnames ?
+ mkshort(waypointp->description) :
+ waypointp->shortname);
fprintf(ofd, "<desc>");
fprintf(ofd, "<![CDATA[%s]]>", waypointp->description);
fprintf(ofd, "</desc>\n");
{
fprintf(ofd, "<?xml version=\"1.0\"?>\n");
fprintf(ofd, "<gpx\n\tversion=\"1.0\">\n");
+ setshort_length(32);
waypt_disp_all(gpx_waypt_pr);
fprintf(ofd, "</gpx>\n");
}
{
mapsource_file_in = fopen(fname, "r");
if (mapsource_file_in == NULL) {
- fprintf(stderr, "Cannot open '%s' for reading\n", fname);
- exit(1);
+ fatal("Cannot open '%s' for reading\n", fname);
}
}
{
mapsource_file_out = fopen(fname, "w");
if (mapsource_file_out == NULL) {
- fprintf(stderr, "Cannot open '%s' for writing\n", fname);
+ fatal("Cannot open '%s' for writing\n", fname);
exit(1);
}
}
--- /dev/null
+PNAME="wine -- ./gpsbabel"
+
+# Geocaching .loc
+rm -f /tmp/gl.loc
+${PNAME} -i geo -f geocaching.loc -o geo -F /tmp/gl.loc
+diff /tmp/gl.loc ../reference
+
+# GPSUtil
+rm -f /tmp/gu.wpt
+${PNAME} -i geo -f geocaching.loc -o gpsutil -F /tmp/gu.wpt
+diff /tmp/gu.wpt ../reference
+
+# GPSman
+rm -f /tmp/gm.gm /tmp/gm.gm+
+${PNAME} -i geo -f geocaching.loc -o gpsman -F /tmp/gm.gm
+${PNAME} -i gpsman -f /tmp/gm.gm -o gpsutil -F /tmp/gm.gm+
+diff /tmp/gm.gm+ /tmp/gu.wpt
+
+# GPX
+rm -f /tmp/gl.gpx /tmp/gpx.gpx
+${PNAME} -i geo -f geocaching.loc -o gpx -F /tmp/gl.gpx
+${PNAME} -i gpx -f /tmp/gl.gpx -o gpsutil -F /tmp/gpx.gpx
+diff /tmp/gpx.gpx /tmp/gu.wpt
+
+# Magellan Mapsend
+rm -f /tmp/mm.mapsend /tmp/mm.gps
+${PNAME} -i geo -f geocaching.loc -o mapsend -F /tmp/mm.mapsend
+${PNAME} -i mapsend -f /tmp/mm.mapsend -o gpsutil -F /tmp/mm.gps
+diff /tmp/mm.gps /tmp/gu.wpt
+
+# Garmin Mapsource
+rm -f /tmp/mm.mapsource /tmp/ms.gps
+#${PNAME} -i geo -f geocaching.loc -o mapsource -F /tmp/mm.mapsource
+#${PNAME} -i mapsource -f /tmp/mm.mapsource -o gpsutil -F /tmp/ms.gps
+# diff /tmp/ms.gps /tmp/gu.wpt
+
+# Magellan serial
+# TODO
+
+
+# CSV (Comma separated value) data.
+
+#${PNAME} -i geo -f geocaching.loc -o csv -F /tmp/csv.csv
+#${PNAME} -i csv -f /tmp/csv.csv -o gpsutil -F /tmp/csv2.csv
+#diff /tmp/csv2.csv /tmp/gu.wpt
+
+# PCX (Garmin mapsource import) file format
+rm -f /tmp/mm.pcx /tmp/pcx.gps
+${PNAME} -i geo -f geocaching.loc -o pcx -F /tmp/mm.pcx
+${PNAME} -i pcx -f /tmp/mm.pcx -o gpsutil -F /tmp/pcx.gps
+diff /tmp/mm.gps /tmp/gu.wpt
+
+# Magellan file format
+${PNAME} -i magellan -f ../reference/magfile -o magellan -F /tmp/magfile
+diff /tmp/magfile ../reference/magfile
+
static const char *badchars = DEFAULT_BADCHARS;
static int mustupper = 0;
+static const char needmem[] =
+ "mkshort: could not reallocate memory for string\n";
/*
* This is the stuff that makes me ashamed to be a C programmer...
if (!ostring) {
- abort();
+ fatal("mkshort: could not reallocate memory for string\n");
}
/*
strncmp(ostring, "the ", 4) == 0) {
nstring = strdup(ostring + 4);
if (!nstring) {
- abort();
+ fatal(needmem);
}
free(ostring);
ostring = nstring;
*/
tstring = strdup(ostring);
if (!tstring) {
- abort();
+ fatal(needmem);
}
l = strlen (tstring);
cp = ostring;
*/
tstring = strdup(ostring);
if (!tstring) {
- abort();
+ fatal(needmem);
}
l = strlen (tstring);
cp = ostring;
tstring = strdup(ostring);
if (!tstring) {
- abort();
+ fatal(needmem);
}
/*